/*     */ package com.jsalipay.util;
/*     */ 
/*     */ import com.alipay.config.AlipayConfig;
/*     */ import java.io.BufferedReader;
/*     */ import java.io.InputStreamReader;
/*     */ import java.net.HttpURLConnection;
/*     */ import java.net.URL;
/*     */ import java.util.Map;
/*     */ 
/*     */ public class AlipayNotify
/*     */ {
/*     */   private static final String HTTPS_VERIFY_URL = "https://www.alipay.com/cooperate/gateway.do?service=notify_verify&";
/*     */   private static final String HTTP_VERIFY_URL = "http://notify.alipay.com/trade/notify_query.do?";
/*     */ 
/*     */   public static boolean verify(Map<String, String> params)
/*     */   {
/*  43 */     String mysign = getMysign(params);
/*  44 */     String responseTxt = "true";
/*  45 */     if (params.get("notify_id") != null) responseTxt = verifyResponse((String)params.get("notify_id"));
/*  46 */     String sign = "";
/*  47 */     if (params.get("sign") != null) sign = (String)params.get("sign");
/*     */ 
/*  59 */     return (mysign.equals(sign)) && (responseTxt.equals("true"));
/*     */   }
/*     */ 
/*     */   private static String getMysign(Map<String, String> Params)
/*     */   {
/*  71 */     Map sParaNew = AlipayCore.paraFilter(Params);
/*  72 */     String mysign = AlipayCore.buildMysign(sParaNew);
/*  73 */     return mysign;
/*     */   }
/*     */ 
/*     */   private static String verifyResponse(String notify_id)
/*     */   {
/*  87 */     String transport = AlipayConfig.transport;
/*  88 */     String partner = AlipayConfig.partner;
/*  89 */     String veryfy_url = "";
/*  90 */     if (transport.equalsIgnoreCase("https"))
/*  91 */       veryfy_url = "https://www.alipay.com/cooperate/gateway.do?service=notify_verify&";
/*     */     else {
/*  93 */       veryfy_url = "http://notify.alipay.com/trade/notify_query.do?";
/*     */     }
/*  95 */     veryfy_url = veryfy_url + "partner=" + partner + "&notify_id=" + notify_id;
/*     */ 
/*  97 */     return checkUrl(veryfy_url);
/*     */   }
/*     */ 
/*     */   private static String checkUrl(String urlvalue)
/*     */   {
/* 110 */     String inputLine = "";
/*     */     try
/*     */     {
/* 113 */       URL url = new URL(urlvalue);
/* 114 */       HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
/* 115 */       BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
/*     */ 
/* 117 */       inputLine = in.readLine().toString();
/*     */     } catch (Exception e) {
/* 119 */       e.printStackTrace();
/* 120 */       inputLine = "";
/*     */     }
/*     */ 
/* 123 */     return inputLine;
/*     */   }
/*     */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.jsalipay.util.AlipayNotify
 * JD-Core Version:    0.6.0
 */